import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @Author: YCKOKO
 * @Date: 2023-04-08
 * @Time:13:23
 * @Description:
 */
public class demo5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        Set<Integer> visited = new HashSet<>();
        int[] nums = new int[num];
        int cost = 0;
        for (int i = 0; i < num; i++) {
            nums[i] = scanner.nextInt();
        }
        Arrays.sort(nums);
        for (int n:
                nums) {
            System.out.print(n+" ");
        }
        System.out.println();

        int start = nums.length-1;
        while (start >= 0){
            int cost1 = 0;
            int cost2 = 0;
            while(start >= 0){
                if(!visited.contains(nums[start])){
                    cost += nums[start];
                    visited.add(nums[start]);
                    cost1 = nums[start];
                    start--;
                    break;
                }
                start--;
            }
            while(start >= 0){
                if(!visited.contains(nums[start])){
                    cost += nums[start];
                    visited.add(nums[start]);
                    cost2 = nums[start];
                    start--;
                    break;
                }
                start--;
            }

            for (int i = start; i >= 0; i--) {
                if(Math.min(cost1,cost2)/2 >= nums[i]){
                    visited.add(nums[i]);
                    break;
                }
            }
        }
        System.out.println(cost);
    }



}
